<template>
  <SModal
      v-model:show="modalShow"
      :title="modalTitle" @positive-click="onSubmit"
  >
    <SForm
        ref="formRef"
        :model="formValue"
    >
      <n-gi :span="12">
        <SFormInput name="musicName" label="歌名" required v-model:value="formValue.musicName" @load-rules="loadRules"/>
      </n-gi>
      <n-gi :span="12">
        <SFormSelect name="singerId" :data="singerList" label="歌手" required v-model:value="formValue.singerId" @load-rules="loadRules"/>
      </n-gi>
<!--      <n-gi :span="24">-->
<!--        <SFormInput name="intro" type="textarea" label="简介" required v-model:value="formValue.intro" @load-rules="loadRules"/>-->
<!--      </n-gi>-->
    </SForm>
  </SModal>
</template>
<script setup>
import SFormInput from "@/components/public/extForm/SFormInput.vue";
import SForm from "@/components/public/extForm/SForm.vue";
import SFormSelect from "@/components/public/extForm/SFormSelect.vue";
import { querySingerSelect} from "@/api/music/singerApi";
import SModal from "@/components/public/SModal/SModal.vue";
import useSModal from "@/components/public/SModal/useSModal";
import {getMusicInfo, updateMusic} from "@/api/music/musicApi";

const api = {
  editApi:updateMusic,
  getInfoById:getMusicInfo
}
const formDefValue = {

}
const {
  onEdit,
  loadRules,
  modalShow,
  modalLoading,
  modalTitle,onSubmit,
  formValue,
  formRef,
} = useSModal("歌曲",formDefValue,api);

defineExpose({
  onEdit,
  modalLoading
})
const singerList = ref([])
onMounted(()=>{
})
watch(()=>modalShow.value,(value)=>{
  if (value){
    querySingerSelect().then(res=>{
      singerList.value = res.data
    })
  }

})
</script>